home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / Threads Interface / CCooperativeThread.c next >
Encoding:
C/C++ Source or Header  |  1994-04-03  |  997 b   |  42 lines  |  [TEXT/KAHL]

  1. /***
  2.  * CCooperativeThread.c
  3.  *
  4.  *  Implement a cooperative thread
  5.  *        Copyright © Gordon Watts 1994
  6.  *
  7.  ***/
  8. #include "CCooperativeThread.h"
  9. #include <Exceptions.h>
  10. #include "util.h"
  11.  
  12. /**
  13.  * Start a cooperative thread on its way
  14.  *
  15.  **/
  16. void CCooperativeThread :: Start (void)
  17. {
  18.     ThreadID    theID;
  19.  
  20.     TestMemory();
  21.  
  22.     AssertStr (theThread == kNoThreadID, "\pStarting already started thread!");
  23.  
  24.     FailOSErr (NewThread (kCooperativeThread,            /* Allow interuptions */
  25.                           &ThreadExtProc,                /* The thing that is going be called */
  26.                           (void *) this,                /* Argument -- this object */
  27.                           theStackSize,                    /* How much space to allocate */
  28.                           theOptions,                    /* Runtime options (like suspended) */
  29.                           0L,                            /* We don't care about the outcome */
  30.                           &theID));                        /* The thread id comming back */
  31.  
  32.     theThread = theID;
  33.     
  34.     if (theID == kNoThreadID)
  35.         Failure (errCouldNotMakeThread, 0L);
  36.  
  37.     /**
  38.      ** Get the thread switcher up and runnign!
  39.      **/
  40.  
  41.     SetupThreadSwitcher (FALSE);
  42. }